<template>
  <div class="buy">
    <div class="cart" @click="$router.push('/cart')">
      <nut-badge :value="$store.getters['cartModule/cartNum']">
        <img src="@/assets/product/cart.png" />
      </nut-badge>
      <span>购物车</span>
    </div>
    <div class="btn">
      <nut-button
        :disabled="disabled"
        type="primary"
        @click="emits('addCart')"
        >加入购物车</nut-button
      >
      <nut-button :disabled="disabled" type="primary" @click="emits('buy')"
        >立即购买</nut-button
      >
    </div>
  </div>
</template>

<script setup>
import { defineProps, defineEmits } from "vue";

// 属性
const props = defineProps({
  disabled: {
    type: Boolean,
  },
});

// 方法
const emits = defineEmits(["buy", "addCart"]);
</script>

<style lang="less" scoped>
.buy {
  width: 100%;
  background: #fff;
  position: fixed;
  bottom: 0px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  height: 65px;
  border-bottom: 1px solid #666;
  .cart {
    width: 70px;
    display: flex;
    flex-direction: column;
    align-items: center;
    font-size: 10px;
    margin-top: 5px;
    img {
      width: 24px;
      height: 24px;
    }
  }
  .btn {
    .nut-button {
      margin-right: 10px;
      font-size: 13px;
    }
  }
}
</style>